package com.itheima.web.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-14 20:32
 * @description
 */
//@ControllerAdvice
public class MyControllerAdvice {

    @ExceptionHandler(ArithmeticException.class)
    public ModelAndView catchException1(){
        System.out.println("出现除0异常!!!!");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error/500");
        return modelAndView;

    }

    @ExceptionHandler(RuntimeException.class)
    public ModelAndView catchException2(){

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error/500");
        return modelAndView;
    }
}
